package edu.towsom.cosc.cosc455.ksmith73;

import java.util.*;

public class MyLexicalAnalyzer implements LexicalAnalyzer{

	public static void main(String[] args) {
		
		//Define token list 
		private List<String> tags = new ArrayList<String>(Arrays.asList("#start document", "#end document", "#start head",
				"#end head", "#start title", "#end title","#start paragraph", "#end paragraph", "#start bold", 
				"#end bold", "#start italics", "#end italics", "#start list", "#end list", "#start item", "#end item", 
				"#start audio", "#end audio", "#newline", "#start video", "#end video", "#start define", "#end define", 
				"#name", "#value", "#start use", "#end use"));
		//Declare other variables
		MySyntaxAnalyzer Syntax = new MySyntaxAnalyzer();
		int index = 0;
		char lexeme;
		StringBuildier token - new String Builder ();
		Compiler compile = new Compiler();
		boolean tag;
		
		//Methods
		//Get next Token method
		public void getNextToken(){
			getCharacter();
			if(tag){
				if(lookupToken()){
				}
				else{
					error("No Token was found.");
				}
			}
		}
		
		//Add character method
		public void addCharacter() {
			token.append(lexeme);
			index++;
		}
		
		//Check for space method
		public boolean isSpace(String x){
			if(c.charAt(index) == ' '){
				return true;
			}
			else {
				return false;	
			}
		}
		
		//Looks up the token to see if it is legal
		public boolean lookToken(){
			if(tag.contains(Syntax.currentToken)){
				return true;
			}
			else { 
				return false;
			}
		}
		
		//Error message using Exception Handling
		public void error(String x;){
			System.out.println("Lexical error. Goodbye!", x);
			System.exit(0);
		}
		
		//Get character method 
		//Uses last four methods
		public void getCharacter(){
			lexeme = compiler.mkd.charAt(index);
			addCharacter();
			if (lexeme == '#'){
				tag = true;
				lexeme = compiler.mkd.charAt(index);
				if(lexeme == 's'){
					addCharacter();
					while(!isSpace(String.valueOf(lexeme))){
						lexeme = compiler.mkd.charAt(index);
						addCharacter();
					}
				}
				else {
					tag = false;
					while(!isSpace(String.valueOf(lexeme))){
						lexeme = compiler.mkd.charAt(index);
						addCharacter();
					}
				}
			}
			else {
				while(compiler.mkd.charAt(index + 1) == '#'){
					lexeme = compiler.mkd.charAt(index);
					addCharacter();
				}
			}
		}
		

	}

}
